package com.blog.dazi.Controller;

import com.blog.dazi.Service.FriendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/dazi/friend")
public class FriendController {

    @Autowired
    private FriendService friendService;

    /**
     * 关注
     * @param tel
     * @param daziNum
     * @return
     */
    @GetMapping("/make")
    public int save(String tel,String daziNum){
        return friendService.makeFriend(tel,daziNum);
    }

    /**
     * 取消关注
     * @param tel
     * @param daziNum
     * @return
     */
    @GetMapping("/close")
    public int close(String tel,String daziNum){
        return friendService.closeFriend(tel,daziNum);
    }

    /**
     * 根据关注和被关注信息查询
     * @param tel
     * @param daziNum
     * @return
     */
    @GetMapping("/findByTelAndDazi")
    public List<Map<String, Object>> findByTelAndDazi(String tel, String daziNum){
        return friendService.findByTelAndDazi(tel,daziNum);
    }

    /**
     * 根据用户手机号查询关注者
     * @param tel
     * @return
     */
    @GetMapping("/list")
    public List<Map<String, Object>> list(String tel){
        return friendService.list(tel);
    }
}
